// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import ElementUI from 'element-ui'
import App from './App'
import router from './router'
import VueAwesomeSwiper from 'vue-awesome-swiper'
import VueTouch from 'vue-touch'
import store from './store'
import IconSvg from '@/components/base/icon-svg/icon-svg'
import { DatetimePicker } from 'vant'
import { Slider } from 'vant'


Vue.config.productionTip = false


import '@/assets/styles/fonts/iconfont.js'
import '@/assets/styles/fonts/symbol.css'
import '@/assets/styles/index.styl'
import '@/assets/styles/border.css'
import '@/assets/styles/fonts/iconfont.css'
import 'swiper/dist/css/swiper.css'
import 'element-ui/lib/theme-chalk/index.css'
import { formatDate } from '@/assets/js/util'
/* eslint-disable no-new */

Vue.use(VueAwesomeSwiper)
Vue.use(ElementUI)
Vue.use(VueTouch, {name: 'v-touch'})
Vue.use(DatetimePicker)
Vue.use(Slider)


Vue.filter('formater', formatDate)
Vue.filter('formatPercent', function(num) {
  return (num * 100).toString().slice(0, 4) + '%'
})


Vue.component('icon-svg', IconSvg)
// 路由验证 
// router.beforeEach((to, from, next) => {
//   let user = store.state.user 
//   let isLogin = user.isLogin
//   if (isLogin) {
//     if (to.path == '/login') {
//       next({path: '/'})
//     } else {
//       next()
//     }
//   } else {
//     if (to.meta.requireAuth) {
//       next()
//       next({path: '/login'})
//     } else {
//       next()
//     }
//   }
// })

router.afterEach((to,from,next) => {
  window.scrollTo(0, 0)
})

new Vue({
  el: '#app',
  router,
  store,
  components: { App },
  template: '<App/>'
})
